import React from "react";
import { Route } from "react-router-dom";
import { mapRoutes } from "./utils";
import Loadable from "react-loadable";
import { Spin, Space } from "antd";
import dma from "~/product/lib_dma";

const Loading = () => (<Space size="middle"><Spin /></Space>);
const Home = Loadable({
  loader: () => import(/* webpackChunkName: "home" */ "../pages/Home"),
  loading: Loading,
});
const Foo = Loadable({
  loader: () => import(/* webpackChunkName: "foo" */ "../pages/Foo"),
  loading: Loading,
});
const NotFound = Loadable({
  loader: () => import(/* webpackChunkName: "404" */ "./404.jsx"),
  loading: Loading,
});

// libraries 入口注入
let routes = [
  <Route path="/" key={"home"} component={Home} exact></Route>,
  <Route path="/foo" key={"foo"} component={Foo}></Route>,
  <Route path="/foo/foo" key={"fooBoo"} component={Foo}></Route>,
  ...mapRoutes(dma),
  <Route path="/notFound" key={"notFound"} component={NotFound} exact></Route>,
];

export default routes;
